/*
 * NaryTree.java
 *
 * Created on July 12, 2006, 11:10 AM
 *
 */

package galronnlp.util;

import java.util.LinkedList;
import java.util.Iterator;

/**
 *
 * @author Daniel A. Galron
 */
public class NaryTree extends Tree {
    private boolean displayProbs = true;
    private TreeStringGenerator stringGen = new PennTreebankStringTreeGenerator(displayProbs);
    
    /** Creates a new instance of NaryTree */
    public NaryTree(Symbol cat, LinkedList<Tree> children, double prob) {
        this.type = this.NARY;
        this.category = cat;
        for(Iterator<Tree> it = children.iterator(); it.hasNext(); ) {
            Tree child = it.next();
            child.setParent(this);
            this.children.addLast(child);
        }
        this.probability = prob;
        
    }
    
    public NaryTree(Symbol cat, LinkedList<Tree> children) {
        this(cat, children, 0.0);
    }

    public boolean equals(Object o) {
        Tree other = (Tree)o;
        boolean ret = false;
        if(other.children.size() == this.children.size()) {
            ret = this.category.equals(other.category);
            for(int i = 0; i < this.children.size(); i++) {
                ret &= ((Tree)this.children.get(i)).equals((Tree)other.children.get(i));
            }
        }
        return ret;
    }
    
    public LinkedList<Symbol> RHS() {
        return children;
    }
}
